import toast from '@/package/hema-toast';

const Components = [];

const install = (Vue) => {
  if (install.installed) return;
  Components.forEach(component => {
    Vue.component(component.name, component);
  });

  // eslint-disable-next-line no-param-reassign
  Vue.prototype.$toast = toast;
};

// auto install
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue); // 通过use方式全部引入
}

const API = {
  install,
  ...Components,
};

export default API; // 通过插件单独引入
